<template>
    <div class="login">
        <div class="loginContent">
            <div class="title">
                <div class="welcome">欢迎登录•</div>
                <div class="platform">后台管理</div>
            </div>
            <div class="form">
                <el-form ref="form" :model="form">
                    <el-form-item>
                        <el-input prefix-icon="el-icon-s-custom" placeholder="请输入您的邮箱" v-model="form.mall"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-input type="password" prefix-icon="el-icon-lock" placeholder="请输入您的密码" v-model="form.password"></el-input>
                    </el-form-item>
                    <div class="passwordBox">
                        <div class="Rememb">
                            <el-checkbox>记住密码？</el-checkbox>
                        </div>
                        <div class="forgetThePassword point">
                            忘记密码
                        </div>
                    </div>
                </el-form>
            </div>
            <div class="loginBtn">
                <el-button @click="Login" type="primary">登录</el-button>
            </div>
            <div class="noneAccount">
                没有账号,
                <span @click="register" class="point">立即注册</span>
            </div>
        </div>
    </div>
</template>

<script>
import { login } from '@/api/login.js'
export default {
    name:"Login",
    data(){
        return {
            form:{
                mall:"",     //账号(采用邮箱登录方式)
                password:"",    //密码
            }
        }
    },
    created(){

    },
    methods:{
        register(){
            this.$message.warning('后台管理不支持用户自行注册,如有问题请联系管理员！')
        },
        Login(){
            if(this.form.mall.trim()==''){
                return this.$message.warning('请填写账号!')
            }else if(this.form.password.trim()==''){
                return this.$message.warning('请填写密码!')
            }
            login({
                mail:this.form.mall,
                password:this.form.password
            }).then(res=>{
                if(res.code==200){
                    this.$router.replace('/home')
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
.login{
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 760px;
    min-height: 100vh;
    background-image: url(../../static/image/bj.png);
    background-size: 100%;
    .loginContent{
        width: 35%;
        height: 400px;
        background-color: white;
        border-radius: 3px;
        padding: 20px 40px;
        box-sizing: border-box;
        box-shadow: 4px 18px 10px 1px rgba(0,0,0,.2);
        .title{
            display: flex;
            align-items: center;
            justify-content: center;
            height: 60px;
            font-size: 30px;
            .welcome{}
            .platform{
                color: rgb(53, 141, 255);
            }
        }
        .form{
            margin:30px 0px 20px 0px;
            //修改element样式
            .el-form-item{
                margin-bottom: 15px;
            }
            .passwordBox{
                display: flex;
                justify-content:space-between;
                color: #535353;
                .Rememb{}
                .forgetThePassword{
                    float: right;
                    font-size: 14px;
                }
            }
        }
        .loginBtn{
            .el-button{
                width: 100%;
            }
        }
        .noneAccount{
            text-align: center;
            margin-top: 30px;
            color: #626161;
            span{
                color: rgb(53, 141, 255);
            }
        }
    }
}
</style>